<template>
    <div class="app-container">
        <div class="block">
            <el-row>
                <el-col :span="24">
                    <el-button type="success" icon="el-icon-plus" @click.native="add">{{ $t('button.add') }}</el-button>
                    <el-button type="primary" icon="el-icon-edit" @click.native="edit">{{ $t('button.edit') }}</el-button>
                    <el-button type="danger" icon="el-icon-delete" @click.native="remove">{{ $t('button.delete') }}</el-button>
                </el-col>
            </el-row>
        </div>


        <el-table :data="list" v-loading="listLoading" element-loading-text="Loading" border fit highlight-current-row
                  @current-change="handleCurrentChange">
            <el-table-column label="序号" type="index" show-overflow-tooltip width="50" align="center">

            </el-table-column>
            <el-table-column label="社区名称">
                <template slot-scope="scope">
                    {{scope.row.communityName}}
                </template>
            </el-table-column>
            <el-table-column label="名称">
                <template slot-scope="scope">
                    {{scope.row.name}}
                </template>
            </el-table-column>
            <el-table-column label="编号">
                <template slot-scope="scope">
                    {{scope.row.code}}
                </template>
            </el-table-column>
            <el-table-column label="总层数" align="center">
                <template slot-scope="scope" >
                    {{scope.row.totalFloor}}
                </template>
            </el-table-column>
            <el-table-column label="高度" align="center">
                <template slot-scope="scope">
                    {{scope.row.height}}(米)
                </template>
            </el-table-column>
            <el-table-column label="商住类型" align="center">
                <template slot-scope="scope">
                    {{scope.row.typeName}}
                </template>
            </el-table-column>
            <el-table-column label="朝向">
                <template slot-scope="scope">
                    {{scope.row.direction}}
                </template>
            </el-table-column>
            <el-table-column label="梯户">
                <template slot-scope="scope">
                    {{scope.row.ladder}}
                </template>
            </el-table-column>
            <el-table-column label="总面积" align="center">
              <template slot-scope="scope">
                {{scope.row.totalArea}}(平米)
              </template>
            </el-table-column>
            <el-table-column label="创建时间" align="center">
              <template slot-scope="scope">
                {{scope.row.createTime}}
              </template>
            </el-table-column>
            <!--<el-table-column label="是否有影像文件">
                <template slot-scope="scope">
                    {{scope.row.hasFile}}
                </template>
            </el-table-column>-->
        </el-table>

        <el-pagination
                background
                layout="total, sizes, prev, pager, next, jumper"
                :page-sizes="[10, 20, 50, 100,500]"
                :page-size="listQuery.limit"
                :total="total"
                @size-change="changeSize"
                @current-change="fetchPage"
                @prev-click="fetchPrev"
                @next-click="fetchNext">
        </el-pagination>

        <el-dialog
                :title="formTitle"
                :visible.sync="formVisible"
                width="70%">
            <el-form ref="form" :model="form" :rules="rules" label-width="150px">
                <el-row>
                    <el-col :span="12">
                        <!--<el-form-item label="社区ID"  >
                            <el-input v-model="form.communityId" minlength=1></el-input>
                        </el-form-item>-->
                        <el-form-item label="社区" prop="communityId">
                          <el-select v-model="form.communityId" placeholder="请选择">
                            <el-option
                              v-for="item in options.communityIds"
                              :key="item.id"
                              :label="item.name"
                              :value="item.id">
                            </el-option>
                          </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="编号" prop="code" >
                            <el-input v-model="form.code" minlength=1 placeholder="请输入编号"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="名称" prop="name" >
                        <el-input v-model="form.name" minlength=1 placeholder="请输入名称"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="商住类型" prop="type" >
                        <el-select v-model="form.type" placeholder="请选择">
                          <el-option
                            v-for="item in options.type"
                            :key="item.k"
                            :label="item.v"
                            :value="item.k">
                          </el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="总层数" prop="totalFloor" >
                            <el-input v-model.trim="form.totalFloor" placeholder="请输入正整数">
                              <template slot="append">层</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="高度(米)" prop="height" >
                            <el-input v-model.trim="form.height" minlength=1 >
                                <template slot="append">米</template>
                            </el-input>
                        </el-form-item>
                    </el-col>

                    <el-col :span="12">
                        <el-form-item label="朝向" prop="direction" >
                            <el-input v-model="form.direction" minlength=1 placeholder="请输入朝向"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="梯户"  >
                            <el-input v-model="form.ladder" minlength=1 placeholder="请输入梯户"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="总面积" prop="totalArea" >
                        <el-input v-model.trim="form.totalArea" minlength=1 placeholder="请输入正数">
                          <template slot="append">平米</template>
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <!--<el-col :span="12">
                        <el-form-item label="是否有影像文件"  >
                            <el-input v-model="form.hasFile" minlength=1></el-input>
                        </el-form-item>
                    </el-col>-->
                </el-row>
                <el-form-item>
                    <el-button type="primary" @click="save">{{ $t('button.submit') }}</el-button>
                    <el-button @click.native="formVisible = false">{{ $t('button.cancel') }}</el-button>
                </el-form-item>

            </el-form>
        </el-dialog>
    </div>
</template>

<script src="./building_info.js"></script>


<style rel="stylesheet/scss" lang="scss" scoped>
    @import "src/styles/common.scss";
</style>

